#pragma once
#include"RBTree.h"
namespace wzy2
{
	template<class K,class V>
	class mymap
	{
	public:
		struct MapKey
		{
			const K& operator()(const pair<K, V>& key)
			{
				return key.first;
			}
		};

		typedef typename RBTree<K, V, MapKey>::iterator iterator;

		iterator begin()
		{
			return _t.begin();
		}

		iterator end()
		{
			return _t.end();
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool>ret = _t.Insert(make_pair(key, V()));
			return ret.first->second;
		}

		pair<iterator, bool> insert(const pair<K, V>& key)
		{
			return _t.Insert(key);
		}

	private:
		RBTree<K, pair<K,V>, MapKey> _t;
	};
}